#include "GameWinState.h"

GameWinState::GameWinState(BeanieCore* a_core, bool a_renew)
{
	m_core = a_core;

	m_name = "GameWinState";
	m_selfId = GAMEWIN;
	m_swapId = GAMEWIN;
	m_completed = false;
	m_renew = a_renew;
}

void GameWinState::init()
{
	//init the textures for GameTexture and GameButton
	//GameButton inherits from GameTexture so init() calls are the same
	m_winbg.initTexture(m_core,BG_WIN,
		TEX_TOPLEFT,V2D_ZERO,V2D_DOUBLE,0.0f,true);
	m_continue.initTexture(m_core,BTN_CONTINUE,
		TEX_TOPLEFT,V2DF(550,560),V2D_ONES,0.0f,true);

	m_continue.onClick([&](){m_swapId=GAMEMENU;m_completed=true;});
}

void GameWinState::release()
{

}

void GameWinState::input()
{
	m_continue.input();
}

void GameWinState::update()
{
	//call GameTexture and GameButton update()
	//GameTexture update() updates the texture transformation
	//GameButton update() calls the GameTexture update()
	//and runs the onClick() and onHover() action if triggered
	m_winbg.update();
	m_continue.update();
}

void GameWinState::draw()
{
	//call GameTexture and GameButton draw()
	//GameButton inherits the draw() from GameTexture
	//and is not overwritten, so it does the same
	//used to draw the sprite; update() and draw()
	//needs to be used together to work properly
	m_winbg.draw();
	m_continue.draw();
}

void GameWinState::preLoop()
{
	
}

void GameWinState::postLoop()
{

}